/**
 * Copyright &copy; 2016-2022 liuhangjun All rights reserved.
 */
package com.channelsharing.hongqu.portal.api.controller.seckillgoods;

import com.channelsharing.common.entity.Paging;
import com.channelsharing.hongqu.portal.api.controller.BaseController;
import com.channelsharing.hongqu.portal.api.entity.SecKillGoods;
import com.channelsharing.hongqu.portal.api.service.OrderInfoService;
import com.channelsharing.hongqu.portal.api.service.SecKillGoodsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


/**
 * 秒杀商品信息接口Controller
 * @author liuhangjun
 * @version 2018-06-06
 */
@Api(tags = "秒杀商品信息操作接口")
@Validated
@RestController
@RequestMapping("/v1/seckillgoods")
public class SecKillGoodsController extends BaseController {

	@Resource
	private SecKillGoodsService secKillGoodsService;
	@Resource
	private OrderInfoService orderInfoService;

	@ApiOperation(value = "获取单条秒杀商品信息")
	@GetMapping("/{id}")
	public SecKillGoods findOne(@PathVariable Long id){
		SecKillGoods secKillGoods = secKillGoodsService.findOne(id);
		if (secKillGoods == null)
			secKillGoods =  new SecKillGoods();
		return secKillGoods;
	}

	@ApiOperation(value = "获取商品信息列表-简单搜索接口")
	@GetMapping("/list")
	public Paging<SecKillGoods> findPaging(
			@RequestParam(defaultValue = "0") Integer offset,
			@RequestParam(defaultValue = "10") Integer limit){

		SecKillGoods entity = new SecKillGoods();
		entity.setOffset(offset);
		entity.setLimit(limit);
		return secKillGoodsService.findPaging(entity);

	}

}
